<template>
  <div class="hello">
    <h2>Module 多个组件状态处理</h2>
    <p>{{ JSON.stringify($store.getters.sumWithRootCount) }}</p>
    <button @click="incrementIfOddOnRootSum">action执行方法</button>
    <p>返回countA的计算值： {{$store.state.countA}}</p>
  </div>
</template>

<script>
import { mapActions } from 'vuex'
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  methods: {
    ...mapActions(['incrementIfOddOnRootSum'])
  },
  // computed: {
  //   ...mapState('moduleA.countA', {
  //     state: state => state
  //   })
  // },
  mounted () {
    console.log(this.$store.getters.sumWithRootCount)
    console.log(this.$store.state.b.countB)
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
